package main

import (
	"fmt"
	"math/rand"
	"time"
)

// 随机生成20以内的20个非0正整数，打印出来。对生成的数值，第单数个（不是索引）累加求和，第偶数个累乘求积。打印结果
func main() {
	var numbers [20]int
	sum := 0
	product := 1
	randnumber := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < 20; i++ {
		numbers[i] = randnumber.Intn(19) + 1
	}
	fmt.Println("随机数: ", numbers)
	for i, v := range numbers {
		if (i+1)%2 == 0 {
			product *= v
		} else {
			sum += v
		}
	}
	fmt.Println("累积: ", sum)
	fmt.Println("累和: ", product)
}

// 批改意见
// 1. 最后的累积和累和结果输出反了